home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / editors / mutt / me2s_pl7.zoo / mu_edit2 / mc2 / mm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  4.3 KB  |  152 lines

  1. /* mm.h : stuff for the MUTT machine
  2.  */
  3.  
  4. /* Craig Durland    Public Domain
  5.  *   Distributed "as is", without warranties of any kind, but comments,
  6.  *     suggestions and bug reports are welcome.
  7.  */
  8.  
  9. #ifndef __MM_H_INCLUDED
  10. #define __MM_H_INCLUDED
  11.  
  12. #define INTELCPU 0    /* such as 8086, 80286, etc.  0 if anything else */
  13.  
  14. #define RSIZ 300    /* max size of result string */
  15.  
  16. #define OSTACKSIZ 30    /* max operators on op stack */
  17. #define ASTACKSIZ 200    /* max args on arg stack */
  18. #define VSTACKSIZ 1500    /* number of bytes for stack frames, local vars ... */
  19.  
  20.     /* A Mutt code identifier and version controller */
  21. #define MM_MAGIC_NUMBER 0xB1
  22.  
  23. /* ******************************************************************** */
  24. /* ******** you should NOT modify anything below this line ************ */
  25. /* ******************************************************************** */
  26.  
  27.     /* types inbedded in MUTT code */
  28. typedef uint16 address;            /* used to create pc offsets */
  29. typedef uint8  *maddr;            /* MUTT machine address */
  30.  
  31.    /* MMDatum types:  one byte.
  32.     * Used in Mutt programing so be careful if you change the order!
  33.     */
  34. #define VOID      0x01
  35. #define STRING      0x02        /* string constant */
  36. #define NUMBER      0x03
  37. #define REAL      0x04
  38. #define BOOLEAN   0x05
  39. #define BLOB      0x06
  40. #define FCNPTR      0x07
  41. #define OSTRING      0x08        /* string object */
  42. #define LIST      0x09        /* list of objects */
  43. #define CHARACTER 0x0A        /* Don't use! This is a place holder */
  44.  
  45. /* ??? get rid of blob and have: */
  46. #if 0
  47. /* arrays and (asc) might cause problems */
  48. /* would have to implement (cast) */
  49. #define PSTRING      0x10
  50. #define PNUMBER      0x11
  51. #define PREAL      0x12
  52. #define PBOOLEAN  0x13
  53. #endif
  54.  
  55.     /* subtypes (not MMDatums) */
  56. #define INT8      0x81
  57. #define INT16      0x82
  58. #define INT32      0x83
  59.     /* op code types */
  60. #define OPMASK      0xC0    /* to select one of the op cmds */
  61. #define OPADDRESS 0xC0
  62. #define OPNAME       0xC1
  63. #define OPTOKEN      0xC2
  64. #define OPXTOKEN  0xC3
  65. #define OPONAME   0xC4        /* same as OPNAME except name is a OSTRING */
  66.  
  67. typedef struct            /* MM's basic datum structure */
  68. {
  69.   uint8 type;
  70.   union
  71.   {
  72.     char *str;
  73.     int32 num;
  74.     uint8 *blob;
  75.     maddr addr;
  76.     void *object;
  77.   } val;
  78. } MMDatum;
  79.  
  80. typedef struct MMStkFrame        /* a Mutt Machine stack frame */
  81. {
  82.   maddr pc;
  83.   int startframe,
  84.       abase,        /* where the args start */
  85.       vbase,        /* where the local vars start */
  86.       vsptr,
  87.       numargs;        /* number of args in this frame */
  88.   uint8 *gvars;        /* where the global variables are */
  89.   struct MMStkFrame *prev_stkframe;
  90.  
  91.   int lobj_max, lobj_start;
  92.   void *global_object_table;
  93. } MMStkFrame;
  94.  
  95. /* ******************************************************************** */
  96. /* ********************* Code File Header Format ********************** */
  97. /* ******************************************************************** */
  98.  
  99. #define H_ENTRY_POINT         0    /* 2 bytes */
  100. #define H_BYTES_OF_CODE         2    /* 2 bytes */
  101. #define H_NAME_TABLE_OFFSET     4    /* 2 bytes */
  102. #define H_NUMBER_OF_PGMS     6    /* 2 bytes */
  103. #define H_BYTES_OF_GVARS     8    /* 2 bytes */
  104. #define H_MAGIC_NUMBER        10    /* 1 bytes */
  105. #define H_NUM_GLOBAL_OBJECTS    11    /* 2 bytes */
  106.  
  107. #define BYTES_IN_HEADER        13
  108.  
  109. /* ******************************************************************** */
  110. /* ******************************************************************** */
  111. /* ******************************************************************** */
  112.  
  113.     /* pc is a (uint8 *) */
  114. #define GET_UINT8(pc)    *(pc)
  115. #define PUT_UINT8(pc,n)    *(pc) = (n)
  116.  
  117. #if INTELCPU
  118.  
  119. #define GET_INT16(pc)    *(int16 *)(pc)
  120. #define GET_UINT16(pc)    *(uint16 *)(pc)
  121. #define GET_INT32(pc)    *(int32 *)(pc)
  122.  
  123. #define PUT_INT16(pc,n)     *(int16 *)(pc) = (n)
  124. #define PUT_UINT16(pc,n) *(uint16 *)(pc) = (n)
  125. #define PUT_INT32(pc,n)  *(int32 *)(pc) = (n)
  126.  
  127. #else    /* everybody else */
  128.  
  129. #define GET_INT16(pc)    (int16)(*(pc) +(*((pc)+1)<<8))
  130. #define GET_UINT16(pc)    (uint16)(*(pc) +(*((pc)+1)<<8))
  131. #define GET_INT32(pc)    \
  132.     (int32)(*(pc) +(*((pc)+1)<<8) +\
  133.     ((int32)*((pc)+2)<<16) +((int32)*((pc)+3)<<24))
  134.  
  135. #define PUT_INT16(pc,n)   (*(pc) = (n)&0xFF, *((pc)+1) = ((n)>>8)&0xFF)
  136. #define PUT_UINT16(pc,n)  (*(pc) = (n)&0xFF, *((pc)+1) = ((n)>>8)&0xFF)
  137. #define PUT_INT32(pc,n)      \
  138.     (*(pc) = (n)&0xFF, *((pc)+1) = ((n)>>8)&0xFF, \
  139.     *((pc)+2) = ((n)>>16)&0xFF, *((pc)+3) = ((n)>>24)&0xFF)
  140.  
  141. #endif
  142.  
  143. #define GET_ADDRESS(pc)      GET_UINT16(pc)
  144. #define PUT_ADDRESS(pc,n) PUT_UINT16(pc,n)
  145.  
  146. #ifndef TRUE
  147. #define FALSE   0
  148. #define TRUE    1
  149. #endif
  150.  
  151. #endif    /* __MM_H_INCLUDED */
  152.